package main

import (
	"context"
	"fmt"
	"google.golang.org/grpc"
	"google.golang.org/grpc/metadata"
	"grpc_starter/grpc_meta/pb/pb"
)

const (
	target = "127.0.0.1:5001"
)

func main() {
	conn, _ := grpc.Dial(target, grpc.WithInsecure())

	client := pb.NewGreetClient(conn)

	// create meta params
	md := metadata.New(map[string]string{
		"x-token": "sdasdasdasdasdhelsldasld1sdasdasd",
	})

	// use metadata to create context
	ctx := metadata.NewOutgoingContext(context.Background(), md)

	resData, _ := client.SayHello(ctx, &pb.ReqData{
		Message: "golang",
	})
	fmt.Println(resData.Data)

}
